<template>
    <div class="school">    
        <h1>学校{{name}}{{address}}</h1>
        <button @click="send666">发送</button>
    </div>
</template>

<script>
    export default {
        name:"MySchool",
        data(){
            return {
                name:'zzz1',
                address:"zzzzzzzzfffffff",
            }
        },
        methods:{
            send666(){
                this.$bus.$emit('studentHello')
            }
        },
        mounted() {
            this.$bus.$on('schoolHello',()=>{
                console.log("schoolget")
            })
        },
        beforeDestroy() {
            //在组件销毁前解绑自定义事件
            this.$bus.$off('schoolHello')
        },
    }
</script>

<style scoped>
    .school{
        background-color: orange;
    }
</style>